package com.honor.games.wg.events;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.google.common.eventbus.Subscribe;
import com.honor.games.wg.services.WGDebugConsoleService;

@Service
public class DebugEventManager {

	private static Logger logger = LoggerFactory.getLogger(DebugEventManager.class); 
	
	@Autowired
	private WGDebugConsoleService consoleService;
	
	@Subscribe
	public void handleNewCommandEvent(NewCommandEvent event) {
		logger.trace("handleNewCommandEvent(NewCommandEvent : {}) - START", event.getCommand());
		
		String eventCommand = event.getCommand();
		
		if(eventCommand.startsWith("create")) {
			consoleService.handleCreateCommand(eventCommand);
		} else if(eventCommand.startsWith("print")) {
			consoleService.handlePrintObjectCommand(eventCommand);
		} else {
			consoleService.handleUnknownCommand(eventCommand);
		}
		
		logger.trace("handleNewCommandEvent(NewCommandEvent : {}) - STOP", event.getCommand());
	}
	
}
